Ext.onReady(function() {

	Ext.BLANK_IMAGE_URL = 'pic/s.gif';
	Ext.QuickTips.init();
	Ext.lib.Ajax.defaultPostHeader += ";charset=utf-8";

		var head = new Ext.Panel( {
			region : 'north',
			border : false,
			html : '<div style="background:url(pic/main1.gif) repeat-x; height:78px;">'
					+ '<div	style="float:right;margin:10px;font:normal 12px tahoma, arial, sans-serif, 宋体;">'
					+ '登出：<a href="/weihe/j_spring_security_logout">注销</a></div>' + '</div>',
			height : 80
		});
		var foot = new Ext.Panel( {
			region : 'south',
			html : '<div style="background:url(pic/main2.gif) repeat-x; height:33px; ">'
					+ '<div style="float:left;font:normal 12px tahoma, arial, sans-serif, 宋体;margin:10px 0 0 10px;">'
					+ 'Power By:	<span style="color:blue">佛山市安讯智能科技有限公司</span> &nbsp;</div>'
					+ '<div	style="float:right;margin:10px;font:normal 12px tahoma, arial, sans-serif, 宋体;" >'
					+ '版权所有：<a href="http://web.ansure.net">AnSure</a></div>'
					+ '</div>',
			height : 35
		});

		var t1 = new Ext.tree.TreePanel( {
			id: 'tree1',
			title : '惟合贸易管理系统',
			width : 200,
			split : true,
			region : 'west',
			collapseMode :'mini',
			collapsible : true,
			defaults : {
				border : false
			},
			layoutConfig : {
				animate : true
			},
			containerScroll: true,
			autoScroll:true,
			rootVisible : false,
			root : new Ext.tree.AsyncTreeNode( {
				expanded : true,
				children : [{
					text : "订购流程",
					children : [{
								id : "clientManager",
								text : "客户档案管理",
								icon : "pic/msn.gif",
								leaf : true
							   },{
								id : "shopping",
								text : "查看采购单",
								leaf : true
							   },{
								id : "createOrder",
								text : "管理订单",
								leaf : true
							   },{
								id : "createShopping",
								text : "管理采购单",
								leaf : true
							   },{
								id : "bvApply",
								text : "bv申请",
								leaf : true
							   }]
				   },{
					text : "报表管理",
					children : [{
								id : "pack",
								text : "管理装箱清单",
								leaf : true
							   },{
								id : "cnca",
								text : "管理CNCA",
								leaf : true
							   },{
								id : "balance",
								text : "管理结算单",
								leaf : true
							   },{
								text : "报关管理",
								children : [{
												id : "contract",
												text : "合同管理",
												leaf : true
											  },{
											    id : "cmc",
											    text : "发票管理",
											    leaf : true
											  },{
												 id : "pk",
												 text : "装箱单管理",
												 leaf : true}]
							   }]
				   },{
					text : "仓库管理",
					children : [ {
						id : "warehousing",
						text : "产品入库登记",
						leaf : true
					  },{
						id : "picking",
						text : "产品领料登记",
						leaf : true
					  },{
						id : "sale",
						text : "产品出库登记",
						leaf : true
					  },{
						id : "transfer",
						text : "调拨登记",
						leaf : true
					  },{
						id : "inventory",
						text : "盘点登记",
						leaf : true
					  },{
						id : "storage",
						text : "库存管理",
						leaf : true
					}]
				},{
					id : "financeManager",
					text : "财务管理",
					children : [{
						text : "发票-退税管理",
						children : [{
							id : "track",
							text : "发票管理",
							leaf : true
					  	},{
							id : "unSubmit",
							text : "未提交退税",
							leaf : true
					  	},{
							id : "unDb",
							text : "提交未退税",
							leaf : true
					  	},{
							id : "drawBack",
							text : "已退税",
							leaf : true
					  }]
				  },{
						text : "销售明细管理",
						children : [ {
							id : "lSell",
							text : "国内销售明细管理",
							leaf : true
					  	},{
							id : "oSell",
							text : "国外销售明细管理",
							leaf : true
					  	}]
				  },{
						text : "费用管理",
						children : [ {
							id : "lFee",
							text : "国内费用管理",
							leaf : true
					  	},{
							id : "oFee",
							text : "国外费用管理",
							leaf : true
					  	},{
							id : "lTax",
							text : "国内税费管理",
							leaf : true
					  	},{
							id : "oTax",
							text : "国外税费管理",
							leaf : true
					  	}]
				  },{
						text : "桑德收付管理",
						children : [ {
							id : "sdRecei",
							text : "应收款管理",
							leaf : true
					  	},{
							id : "sdPay",
							text : "应付款管理",
							leaf : true
					  	}]
				  },{
						text : "应收款管理",
						children : [ {
							id : "lRecei",
							text : "国内应收款管理",
							leaf : true
					  	},{
							id : "oRecei",
							text : "国外应收款管理",
							leaf : true
					  	}]
				  },{
						text : "应付款管理",
						children : [ {
							id : "lSpay",
							text : "国内应付款管理",
							leaf : true
					  	},{
							id : "oSpay",
							text : "国外应付款管理",
							leaf : true
					  	}]
				  },{
							text : "销售成果管理",
							children : [ {
								id : "selfH",
								text : "自营业务管理",
								leaf : true
						  	},{
								id : "actH",
								text : "代理业务管理",
								leaf : true
						  	},{
								id : "otherH",
								text : "其他业务管理",
								leaf : true
						  	},{
								id : "harvest",
								text : "成果统计",
								leaf : true
						  	}]
					  },{
							text : "国内资金管理",
							children : [ {
								id : "lfund",
								text : "货币资金",
								leaf : true
						  	},{
								id : "lfRecei",
								text : "当日收款",
								leaf : true
						  	},{
								id : "lfPay",
								text : "当日付款",
								leaf : true
						  	},{
								id : "lshallcei",
								text : "待收款项",
								leaf : true
						  	},{
								id : "lshallpay",
								text : "待付款项",
								leaf : true
						  	}]
					  },{
							id : "runcost",
							text : "经营成本管理",
							leaf : true
					  	},{
							id : "stat",
							text : "贷款统计管理",
							leaf : true
					  	}]
					
			  },{
					text : "用户管理",
					children : [ {
								id : "user",
								text : "账户管理",
								leaf : true
								}]
			     }]
			})
		});

		var t2 = new Ext.tree.TreePanel( {
			border : false,
			rootVisible : false,
			root : new Ext.tree.AsyncTreeNode( {
				text : "主数据管理",
				expanded : true,
				children : [ {
					id : "user",
					text : "用户管理",
					leaf : true
				},{
					id : "permissions",
					text : "权限管理",
					children : [ {
						id : "permission",
						text : "权限管理",
						leaf : true
					}, {
						id : "permissionType",
						text : "权限类别",
						leaf : true
					}]
				}]
			})

		});

		var leftmenu = new LeftMenu( {
			containerScroll: true,
			autoScroll : true,
			trees : [t1, t2]
		});

		var mainTab = new MainingPanel( {
			id: 'mainTab',
			style : 'padding:0 6px 0 0',
			region : 'center',
			deferredRender : false,
			activeTab : 0,
			resizeTabs : true,
			inTabWidth : 100,
			tabWidth : 120,
			enableTabScroll : true,
			items : [{
				title : '我的首页',
				html : '<div style="background:url(pic/main.gif) no-repeat center middle; height:508px;"></div>'
			}]
		});

		leftmenu.on("nodeClick", function(nodeAttr) {
			mainTab.loadTab(nodeAttr);
		});
		// 6、创建布局
		
		var viewport = new Ext.Viewport( {
			layout : 'border',
			containerScroll: true,
			style : 'border:#024459 2px solid;',
			items : [head, foot, t1, mainTab]
		});

	});